package org.wattdepot.cli.commands;

import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;

/**
 * This class tests the quit command of the CommandLineInterface's actual commands.
 * @author David Mau
 */
public class TestCommandQuit {
  
  /**
   * Tests the quit command.
   */
  @Test
  public void testQuitCommand() {
    // Create a new help command object.
    QuitCommand command = new QuitCommand( null );
    // Create a new List to store the args
    List<String> args = new ArrayList<String>();
    
    // Get the help output from the command
    String quitOutput = command.doCommand( args );
    // Ready the expected output
    String output;
    output = WattDepotCliCommand.closingProgram;
    
    // Compare the given output to what is expected
    int result = quitOutput.compareTo(output);
    assertSame("Checking quit command", result, 0);
  }
  
  /**
   * Tests to see if the quit command can handle excess arguments.
   */
  @Test
  public void testExcessArguments() {
    // Create a new quit command object.
    QuitCommand command = new QuitCommand(null);
    // Create a new List to store the args
    List<String> args = Arrays.asList("1");
    
    // Get the output from the command
    String sourceOutput = command.doCommand( args );

    // Make sure that the command is returning the error properly
    assertTrue("Checking excess Quit argument handling", 
        sourceOutput.contains(WattDepotCliCommand.tooManyArguments));
  }
}
